package flc.ast.utils;

import com.blankj.utilcode.util.GsonUtils;
import com.blankj.utilcode.util.SPUtils;
import com.google.gson.reflect.TypeToken;

import java.util.List;

import flc.ast.bean.MyRecordBean;
import stark.common.apis.base.JtwzdmQueryBean;


public class AppSpUtils {
    private static final String SP_NAME = "appCollSp";
    private static final SPUtils sSpUtils = SPUtils.getInstance(SP_NAME);

    public static void saveRecordList(List<MyRecordBean> list) {
        String json = GsonUtils.toJson(list);
        sSpUtils.put(Key.key_subject_record_list, json);
    }

    public static List<MyRecordBean> getRecordList() {
        String json = sSpUtils.getString(Key.key_subject_record_list);
        return GsonUtils.fromJson(json, new TypeToken<List<MyRecordBean>>() {
        }.getType());
    }

    public static void saveHistoryList(List<JtwzdmQueryBean> list) {
        String json = GsonUtils.toJson(list);
        sSpUtils.put(Key.key_subject_history_list, json);
    }

    public static List<JtwzdmQueryBean> getHisotryList() {
        String json = sSpUtils.getString(Key.key_subject_history_list);
        return GsonUtils.fromJson(json, new TypeToken<List<JtwzdmQueryBean>>() {
        }.getType());
    }

    interface Key {
        String key_subject_record_list = "key_record_list";
        String key_subject_history_list = "key_history_list";

    }
}